﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace AcmeSportsStore
{
    class PurchasedStore
    {
        protected PurchasedItemIndexerByCustId pIndexerByCustId
            = new PurchasedItemIndexerByCustId();

        protected PurchasedItemIndexerByItemId pIndexerByItemId
            = new PurchasedItemIndexerByItemId();

        public PurchasedStore()
        { 
        }

        public int Count
        {
            get
            {
                return pIndexerByCustId.Count;
            }
        }

        public PurchasedItem GetItemByIndexerForCustId(int index)
        {
            return (PurchasedItem)pIndexerByCustId[index];
        }

        public PurchasedItem GetItemByIndexerForItemId(int index)
        {
            return (PurchasedItem)pIndexerByItemId[index];
        }

        public int GetIndexForCustId(PurchasedItem item)
        {
            return pIndexerByCustId.GetIndex(item);
        }

        public int GetIndexForItemId(PurchasedItem item)
        {
            return pIndexerByItemId.GetIndex(item);
        }

        //
        public int GetIndicesForCustIdByCustId(string custId)
        {
            /*
             * get all items contain the same custId
             */
            PurchasedItem dummy = new PurchasedItem(0,"",custId, "", "", "");
            return 0;
        }

        public ArrayList GetItemsByCustId(string custId)
        {
            PurchasedItem dummy = new PurchasedItem(0, "", custId, "", "", "");
            return pIndexerByCustId.GetItems(dummy);
        }

        public int GetIndicesForCustIdByItemId(string ItemId)
        {
            /*
             * get all items contain the same ItemId
             */
            PurchasedItem dummy = new PurchasedItem(0,ItemId,"", "","","");

            return 0;
        }

        public void Clear()
        {
            pIndexerByCustId.Clear();
            pIndexerByItemId.Clear();
        }

        public bool AddItem(PurchasedItem item)
        {
            int index = pIndexerByItemId.Add(item);

            if (index < 0)
            {   /* already exists */
                return false;
            }

            pIndexerByCustId.Add(item);    
            return true;
        }

   
      
    }
}
